package promote.brozen.base.juc;

import promote.brozen.utils.concurrent.Threads;

import java.util.concurrent.Semaphore;

/**
 * @author Brozen
 * @date 2020/8/17 2:27 PM
 * @email brozen@qq.com
 */
public class AQSPropagate {

    public static void main(String[] args) throws InterruptedException {
        Semaphore semaphore = new Semaphore(12);

        semaphore.acquire(12);

        Thread t1 = new Thread(() -> {
            try {
                Threads.silentSleep(100L);
                semaphore.acquire(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        t1.start();

        Thread t2 = new Thread(() -> {
            try {
                Threads.silentSleep(100L);
                semaphore.acquire(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        t2.start();

        System.out.println("Main got");
        semaphore.release(12);

    }

}
